package project;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;

public class SideInfoPanel extends JPanel
{
	private Connection conn = null;
	private JPanel baseP = null, labelP = null;
	private JLabel dateJoinedL = null, moviesRentedL = null, 
			noOfFinesL = null, lastMovieRentedL = null,
			lastRentedDateL = null, ageL = null, creditL = null;
	private JLabel days30L = null, days30SalesL = null, avg30L = null,
				refunds30L = null;
	private JLabel days30L2 = null, days30SalesL2 = null, avg30L2 = null,
						refunds30L2 = null;
	private JLabel 	dateJoinedL2 = null, moviesRentedL2 = null, 
				noOfFinesL2 = null, lastMovieRentedL2 = null,
				lastRentedDateL2 = null, ageL2 = null, creditL2 = null;
	private Font font = null, font2 = null;
	
	public SideInfoPanel(String type, Connection conn, String [] in)
	{
		this.conn = conn;
		if(in.length == 0)
		{
			for(int i = 0; i < in.length; i++)
			{
				in[i] = "";
			}
		}
		String fontName = this.getFont().getFontName();
		font = new Font(fontName, Font.BOLD, 14);
		font2 = new Font(fontName, Font.ITALIC, 15);
		labelP = new JPanel(new GridLayout(7,2));
		labelP.setBackground(new Color(240,230,140));
		
		if(type.equals("Client"))
		{
			labelP.setBorder(BorderFactory.createEmptyBorder(60,70,60,40));
			dateJoinedL = new JLabel("Date Joined: ");
			dateJoinedL.setFont(font);
			moviesRentedL = new JLabel("Total Movies Rented: ");
			moviesRentedL.setFont(font);
			noOfFinesL = new JLabel("No. of Fines: ");
			noOfFinesL.setFont(font);
			lastMovieRentedL = new JLabel("Last Movie Rented: ");
			lastMovieRentedL.setFont(font);
			lastRentedDateL = new JLabel("Date of Last Rental: ");
			lastRentedDateL.setFont(font);
			ageL = new JLabel("Age: ");
			ageL.setFont(font);
			creditL = new JLabel("Current Credit: ");
			creditL.setFont(font);
			dateJoinedL2 = new JLabel(in[2]);
			dateJoinedL2.setFont(font2);
			moviesRentedL2 = new JLabel(in[3]);
			moviesRentedL2.setFont(font2);
			noOfFinesL2 = new JLabel(in[6]);
			noOfFinesL2.setFont(font2);
			lastMovieRentedL2 = new JLabel(in[4]);
			lastMovieRentedL2.setFont(font2);
			lastRentedDateL2 = new JLabel(in[5]);
			lastRentedDateL2.setFont(font2);
			ageL2 = new JLabel(in[0]);
			ageL2.setFont(font2);
			creditL2 = new JLabel("R "+in[1]);
			creditL2.setFont(font2);
			labelP.add(ageL);
			labelP.add(ageL2);
			labelP.add(creditL);
			labelP.add(creditL2);
			labelP.add(dateJoinedL);
			labelP.add(dateJoinedL2);
			labelP.add(moviesRentedL);
			labelP.add(moviesRentedL2);
			labelP.add(lastMovieRentedL);
			labelP.add(lastMovieRentedL2);
			labelP.add(lastRentedDateL);
			labelP.add(lastRentedDateL2);
			labelP.add(noOfFinesL);
			labelP.add(noOfFinesL2);
		}
		if(type.equals("Employee"))
		{
			labelP.setBorder(BorderFactory.createEmptyBorder(60,50,60,30));
			dateJoinedL = new JLabel("Date Joined: ");
			dateJoinedL.setFont(font);
			days30L = new JLabel("No. of Sales - 30 days: ");
			days30L.setFont(font);
			days30SalesL = new JLabel("Revenue - 30 days: ");
			days30SalesL.setFont(font);
			avg30L = new JLabel("Avg. Sales/Day - 30 days: ");
			avg30L.setFont(font);
			refunds30L = new JLabel("Total Refunds - 30 days: ");
			refunds30L.setFont(font);
			ageL = new JLabel("Age: ");
			ageL.setFont(font);
			moviesRentedL = new JLabel("Total Rentals: ");
			moviesRentedL.setFont(font);
			dateJoinedL2 = new JLabel(in[5]);
			dateJoinedL2.setFont(font2);
			days30L2 = new JLabel(in[1]);
			days30L2.setFont(font2);
			days30SalesL2 = new JLabel("R "+in[3]);
			days30SalesL2.setFont(font2);
			avg30L2 = new JLabel(in[6]);
			avg30L2.setFont(font2);
			refunds30L2 = new JLabel(in[4]);
			refunds30L2.setFont(font2);
			ageL2 = new JLabel(in[0]);
			ageL2.setFont(font2);
			moviesRentedL2 = new JLabel(in[2]);
			moviesRentedL2.setFont(font2);
			labelP.add(ageL);
			labelP.add(ageL2);
			labelP.add(avg30L);
			labelP.add(avg30L2);
			labelP.add(dateJoinedL);
			labelP.add(dateJoinedL2);
			labelP.add(moviesRentedL);
			labelP.add(moviesRentedL2);
			labelP.add(days30L);
			labelP.add(days30L2);
			labelP.add(days30SalesL);
			labelP.add(days30SalesL2);
			labelP.add(avg30L);
			labelP.add(avg30L2);
			
		}
		
		baseP = new JPanel(new GridLayout(1,1));
		baseP.setPreferredSize(new Dimension(500,450));
		baseP.setBackground(new Color(240,230,140));
		baseP.add(labelP);
		baseP.setBorder(BorderFactory.createLoweredBevelBorder());
		this.add(baseP, BorderLayout.CENTER);
		
	}
	/*public static void main(String [] args)
	{
		new SideTestFrame();
	}*/
}

/*class SideTestFrame extends JFrame
{
	public SideTestFrame()
	{	
		try
		{
			Connection conn;
			String userid, password;
			userid = "root";
			password = "";
			MySQL_Connection msc = new MySQL_Connection(
					"turtleData","localhost",userid, password);
			conn = msc.getMySQLConnection();
			ClientManager cm = new ClientManager(conn);
			String [] input = cm.getInfoPanel("buc1001");
			SideInfoPanel cp = new SideInfoPanel(conn,input);
			this.setTitle("");
			this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			this.getContentPane().add(cp, BorderLayout.CENTER);
			this.setSize(500,450);
			this.setLocationRelativeTo(null);
			this.setVisible(true);
		}
		catch(SQLException sqlx)
		{
			sqlx.printStackTrace();
		}
		catch(ClassNotFoundException cnfe)
		{
			cnfe.printStackTrace();
		}
	}
}*/